﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
using System.Windows.Media.Imaging;
namespace Day2
{
    public partial class TakePhotoPage : PhoneApplicationPage
    {
        public TakePhotoPage()
        {
            InitializeComponent();
        }

        private void bntTakePhoto_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			CameraCaptureTask cam = new CameraCaptureTask();
			cam.Completed +=new System.EventHandler<Microsoft.Phone.Tasks.PhotoResult>(cam_Completed);
        	cam.Show();
		}

        private void cam_Completed(object sender, Microsoft.Phone.Tasks.PhotoResult e)
        {
        	// TODO: Add event handler implementation here.
    		if(e.TaskResult == TaskResult.OK){
				myImage.Source = new BitmapImage(
						new Uri(e.OriginalFileName,UriKind.Absolute));
			}    
		}
    }
}
